program ex1;

  type letter = 'a'..'z';
  type intArr = array of integer;
  type letterArr = array of letter;
  type stringArr = array of string;
  type encryptToIntFuncType =
     function (v: integer; c: letter) : integer;
  type encryptToLetterFuncType =
     function (v: letter; c: letter) : letter;
  type encryptToStringFuncType =
     function (v: string; c: letter) : string;
  //function encryptToInt(input: letterArr; length: integer; first: integer;
  //   f: encryptToIntFuncType) : intArr;
  //function encryptToLetter(input: letterArr; length: integer; first: letter;
  //   f: encryptToletterFuncType) : letterArr;
  //function encryptToString(input: letterArr; length: integer; first: string;
  //   f: encryptToStringFuncType) : stringArr;

  function encryptToInt(input: letterArr; length: integer; first: integer;
     f: encryptToIntFuncType) : intArr;
    var i: integer;
    begin
	if (length <= 0) then exit;
	setLength (encryptToInt, length);
    encryptToInt[0] := f(first, input[0]);
    if (length = 1) then exit;
    encryptToInt[1] := f(first, input[1]);
	if (length = 2) then exit;
    for i := 2 to length - 1 do
      encryptToInt[i] := f(encryptToInt[i-2], input[i]);
    end;

  function encryptToLetter(input: letterArr; length: integer; first: letter;
     f: encryptToletterFuncType) : letterArr;
    var i: integer;
    begin
	if (length <= 0) then exit;
	setLength (encryptToLetter, length);
    encryptToLetter[0] := f(first, input[0]);
    if (length = 1) then exit;
    encryptToLetter[1] := f(first, input[1]);
	if (length = 2) then exit;
    for i := 2 to length - 1 do
      encryptToLetter[i] := f(encryptToLetter[i-2], input[i]);
    end;

  function encryptToString(input: letterArr; length: integer; first: string;
     f: encryptToStringFuncType) : stringArr;
    var i: integer;
    begin
	if (length <= 0) then exit;
	setLength (encryptToString, length);
    encryptToString[0] := f(first, input[0]);
    if (length = 1) then exit;
    encryptToString[1] := f(first, input[1]);
	if (length = 2) then exit;
    for i := 2 to length - 1 do
      encryptToString[i] := f(encryptToString[i-2], input[i]);
    end;


